#include<iostream>
#include<conio.h>
using namespace std;
//abcxyz
class hinh2D
{
public:
	hinh2D(){};
	virtual void nhap()=0;
	virtual float chuvi()=0;
	virtual float dientich()=0;
};

class hinhvuong : public hinh2D
{
private:
	float a;
public:
	hinhvuong();
	void nhap();
	float chuvi();
	float dientich();
};

hinhvuong::hinhvuong() : hinh2D()
{
	a=0;
}
void hinhvuong::nhap()
{
	cout<<"Nhap vao canh hinh vuong: ";
	cin>>a;
}
float hinhvuong::chuvi()
{
	
	return (a*4);
}
float hinhvuong::dientich()
{
	return a*a;
}

class hinhchunhat : public hinh2D
{
private:
	float a,b;
public:
	hinhchunhat();
	void nhap();
	float chuvi();
	float dientich();
	
};
hinhchunhat::hinhchunhat() : hinh2D()
{
	a=0;
}
void hinhchunhat::nhap()
{
	cout<<"Nhap vao chieu dai HCN: ";
	cin>>a;
	cout<<"Nhap vao chieu rong HCN: ";
	cin>>b;
}
float hinhchunhat::chuvi()
{
	return (a+b)*2;
}
float hinhchunhat::dientich()
{
	return a*b;
}

class hinhtron : public hinh2D
{
private:
	float r;
public:
	hinhtron();
	void nhap();
	float chuvi();
	float dientich();
};
hinhtron::hinhtron() : hinh2D()
{
	r=0;
}
void hinhtron::nhap()
{
	cout<<"Nhap vao ban kinh hinh tron: ";
	cin>>r;
}
float hinhtron::chuvi()
{
	return 3.14*2*r;
}
float hinhtron::dientich()
{
	return 3.14*r*r;
}


int main()
{
	float n;
	cout<<"Nhap vao so luong hinh can xu ly: ";
	cin>>n;
	hinh2D ** hinh = new hinh2D*[n];
	for(int i=0;i<n;i++)
	{
		cout<<"Ban muon nhap hinh:\n1\tHinh Vuong\n2\tHinh Chu Nhat\n3\tHinh Tron";
		float select=getch();

		if(select=='1')
		{
			hinh[i] = new hinhvuong;
		}
		else if(select=='2')
		{
			hinh[i] = new hinhchunhat;
			cout<<endl;
		}
		else if(select=='3')
		{
			hinh[i] = new hinhtron;
			cout<<endl;
		}
		else
		{
			cout<<endl<<endl<<"Hinh ban chon khong hop le,Thu lai:"<<endl;
			--i;
			continue;
		}
			cout<<endl;
			hinh[i]->nhap();
			cout<<"Dien tich: "<<hinh[i]->dientich()<<endl;
			cout<<"Chu vi: "<<hinh[i]->chuvi()<<endl;
	}
	return 1;
	//ewrwefkjbgfggeiufgbe
	//sdfsdfsfsfsfjfbgakjgad;ghaekjaekjghljkghegljWLG'JHGLKJHAEROKUHEROG
	//EFLJHwhguoiasghojagojaghoajvg;oiuaegfaoifgae;iuogerogoiu
}